<template>
    <div class="header-container">
        <div class="l-content">
            <el-button @click="collapseMenu" icon="el-icon-menu" size="mini" style="margin-right: 20px"></el-button>
            <!-- 面包屑 -->
            <el-breadcrumb separator="/">
                <el-breadcrumb-item v-for="item in tags" :to="{ path: item.path }">{{ item.label }}</el-breadcrumb-item>
            </el-breadcrumb>
        </div>
        <div class="r-content">
            <el-dropdown @command="handleCommand">
                <span class="el-dropdown-link">
                    <img class="userImg" src="../assets/img/user.jpg" alt="个人设置" />
                </span>
                <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item command="a">个人中心</el-dropdown-item>
                    <el-dropdown-item command="b">退出</el-dropdown-item>

                </el-dropdown-menu>
            </el-dropdown>
        </div>
    </div>
</template>


<script>
import { mapState } from 'vuex' // vuex 中的数据存储是基于文档的
import Cookie from "js-cookie";

export default {
    data() {
        return {}
    },
    methods: {
        collapseMenu() {
            this.$store.commit('collapseMenu');
        },
        handleCommand(command) {
            if (command === 'b') {
                // 清除Cookie中的token数据
                Cookie.remove('token');
                 // 清除Cookie中的动态路由menu数据
                Cookie.remove('menu');
                // 登出后跳转登录页
                this.$router.push('login')
            }
        },
    },
    computed: {
        ...mapState({
            tags: state => state.tab.tabList
        })
    },
    mounted() {
        console.log(this.tags, "tags")
    }
}
</script>

<style lang="less" scoped>
.header-container {
    padding: 0 20px;
    background-color: #333;
    height: 60px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.text {
    color: #fff;
    font-size: 14px;
    margin-left: 10px;
}

.r-content {
    .userImg {
        width: 40px;
        height: 40px;
        border-radius: 50%;
    }
}

.l-content {
    display: flex;
    align-items: center;

    /deep/.el-breadcrumb__item {
        .el-breadcrumb__inner {
            font-weight: normal;

            &.is-link {
                color: #666666;
            }
        }

        &:last-child {
            .el-breadcrumb__inner {
                color: #ffffff;
            }
        }
    }
}</style>